'''
Created on Mar 26, 2013

@author: nplotnik
'''

import os
import random
import sys
import platform
from subprocess import call
import csv



if len(sys.argv) > 1:
    MAX_FILE_SIZE_IN_MBYTES = int(sys.argv[1]) 
else :
    MAX_FILE_SIZE_IN_MBYTES = 1


MAX_FILE_SIZE_IN_BYTES = 1024*1024*MAX_FILE_SIZE_IN_MBYTES
MAX_ABSOLUTE_VALUE = 100 #sys.maxsize


with open('input', 'w') as file :
    totalSize = 0
    if totalSize < MAX_FILE_SIZE_IN_BYTES :
        number = str(random.randint(-MAX_ABSOLUTE_VALUE, MAX_ABSOLUTE_VALUE))
        file.write(number)
        totalSize += len(number)
    while totalSize < MAX_FILE_SIZE_IN_BYTES :
        number = ',' + str(random.randint(-MAX_ABSOLUTE_VALUE, MAX_ABSOLUTE_VALUE))
        file.write(number)
        totalSize += len(number)

print('Total file size: ' + str(os.path.getsize('input')) + ' bytes')

# outputFileName = 'output'
# 
# 
# def sortFile(filename) :
#     with open(filename, encoding='utf-8') as input:
#         reader = csv.reader(input)
#         for row in reader:
#             row.sort()
#             with open('outputFileName', 'w') as outputFile:
#                 outputFile.write(str(row))
# 
# 
# 
# sortFile('input')
# call(['Debug/Sort', 'input'])

